打酱油

题目 打酱油

image-f1c8d0fc

思路分析

将n尽可能拆成50 30

一个50 +7 一个30 +4 剩余部分+/10

代码实现

#include<bits/stdc++.h>
using namespace std;
#define endl '\n'

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n;cin>>n;
    int ans=0;
    while(n/50){
        ans+=7;
        n-=50;
    }
    while(n/30){
        ans+=4;
        n-=30;
    }
    ans+=n/10;
    cout<<ans;
    return 0;
}

同类题型

视频讲解


⬅️ 小平方 🏠 00-刷题理模型 ➡️ 日期问题